using Unity.VisualScripting;

namespace LS.UGFUnits
{
    [UnitShortTitle("Set String")]
    public class SetStringSetting : SettingUnit
    {
        [DoNotSerialize]
        [PortLabelHidden]
        public ValueInput Name { get; private set; }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueInput Value { get; private set; }
        
        protected override void Definition()
        {
            base.Definition();
            Name = ValueInput<string>(nameof(Name), string.Empty);
            Value = ValueInput<string>(nameof(Value), string.Empty);
            Requirement(Name, Input);
        }

        protected override ControlOutput In(Flow flow)
        {
            string name = flow.GetValue<string>(Name);
            string value = flow.GetValue<string>(Value);
            Target?.SetString(name, value);
            return base.In(flow);
        }
    }
}